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
EscrowFactory
stableescrow.sol
0xd03a329e6a1f05d0c797215a82e8f0e14f241d4b
Solidity
EscrowFactory
contract EscrowFactory is owned { /* 1) The Escrow Factory contract to create and manage Escrows 2) Only the Escrow Factory is owned by the manager 3) The manager has no control over each Escrow or the cumulative payment locked in the Factory contract */ address constant private dai_ = 0x6B175474E89094C44Da98b954EedeAC495271d0F; DaiErc20 constant private daiToken = DaiErc20(dai_); //Escrow Fee in wad payed to the manager to create a Escrow uint public escrowfee; //Switch that controls whether the factory is active bool public factorycontractactive; uint private escrowid; uint constant private maxuint = 2**256-1; struct Escrow { address escrowpayer; address escrowpayee; uint escrowamount; uint escrowsettlementamount; escrowstatus estatus; address escrowmoderator; uint escrowmoderatorfee; } mapping (bytes32 => Escrow) public Escrows; /** Events **/ //Event for new Escrow Contract event NewEscrowEvent(bytes32 esid, address indexed escrowpayer, address indexed escrowpayee, uint escrowamount, uint eventtime); //Event overload with moderator event NewEscrowEvent(bytes32 esid, address indexed escrowpayer, address indexed escrowpayee, uint escrowamount, address indexed escrowmoderator, uint escrowmoderatorfee, uint eventtime); //The Escrowid is indexed event NewEscrowEventById(bytes32 indexed esid, address escrowpayer, address escrowpayee, uint escrowamount, uint eventtime); //The Escrowid is indexed overload for moderator event NewEscrowEventById(bytes32 indexed esid, address escrowpayer, address escrowpayee, uint escrowamount, address escrowmoderator, uint escrowmoderatorfee, uint eventtime); //Escrow Status Change Event event EscrowStatusEvent(bytes32 indexed esid, escrowstatus estatus, uint escrowsettlementamount, uint eventtime); constructor() public { escrowid = 0; escrowfee = 1000000000000000000; //1 DAI factorycontractactive = true; } function setEscrowFee(uint newfee) external onlyManager { /* 1) Changes the Escrow fee that is paid to the manager 2) The Escrow fee at launch of contract is set to 1 DAI 3) The escrowfee is a public variable and can always queried */ require(newfee > 0); escrowfee = newfee; } function setFactoryContractSwitch() external onlyManager { /* 1) Switch that controls whether the contract is active 2) If the contract is paused new Escrows can not be created, but existing Escrows can still be Settled. */ factorycontractactive = factorycontractactive == true ? false : true; } //create new escrow function createNewEscrow(address escrowpayee, uint escrowamount) external { require(factorycontractactive, "Factory Contract should be Active"); require(escrowid < maxuint, "Maximum escrowid reached"); require(msg.sender != escrowpayee,"The Payer, payee should be different"); require(escrowpayee != address(0),"The Escrow Payee can not be address(0)"); require(escrowamount > 0,"Escrow amount has to be greater than 0"); require(daiToken.allowance(msg.sender,address(this)) >= mathlib.add(escrowamount, escrowfee), "daiToken allowance exceeded"); bytes32 esid = keccak256(abi.encodePacked(escrowid)); Escrows[esid] = Escrow({escrowpayer:msg.sender, escrowpayee:escrowpayee, escrowamount:escrowamount, escrowsettlementamount:escrowamount, estatus:escrowstatus.ACTIVATED,escrowmoderator:address(0),escrowmoderatorfee:0}); escrowid = mathlib.add(escrowid,1); //The Esrow Amount gets transferred to factory contract daiToken.transferFrom(msg.sender, address(this), escrowamount); //Transfer the escrow fee to factory manager daiToken.transferFrom(msg.sender, manager, escrowfee); emit NewEscrowEvent(esid, msg.sender, escrowpayee, escrowamount, now); emit NewEscrowEventById(esid, msg.sender, escrowpayee, escrowamount, now); } //create new escrow overload function createNewEscrow(address escrowpayee, uint escrowamount, address escrowmoderator, uint escrowmoderatorfee) external { require(factorycontractactive, "Factory Contract should be Active"); require(escrowid < maxuint, "Maximum escrowid reached"); require(msg.sender != escrowpayee && msg.sender != escrowmoderator && escrowpayee != escrowmoderator,"The Payer, payee & moderator should be different"); require(escrowpayee != address(0) && escrowmoderator!=address(0),"Escrow Payee or moderator can not be address(0)"); require(escrowamount > 0,"Escrow amount has to be greater than 0"); uint dailockedinnewescrow = mathlib.add(escrowamount,escrowmoderatorfee); require(daiToken.allowance(msg.sender,address(this)) >= mathlib.add(dailockedinnewescrow, escrowfee), "daiToken allowance exceeded"); bytes32 esid = keccak256(abi.encodePacked(escrowid)); Escrows[esid] = Escrows[esid] = Escrow({escrowpayer:msg.sender, escrowpayee:escrowpayee, escrowamount:escrowamount, escrowsettlementamount:escrowamount, estatus:escrowstatus.ACTIVATED,escrowmoderator:escrowmoderator,escrowmoderatorfee:escrowmoderatorfee}); escrowid = mathlib.add(escrowid,1); //The Esrow Amount and Moderator fee gets transferred to factory contract daiToken.transferFrom(msg.sender, address(this), dailockedinnewescrow); //Transfer the escrow fee to factory manager daiToken.transferFrom(msg.sender, manager, escrowfee); emit NewEscrowEvent(esid, msg.sender, escrowpayee, escrowamount, escrowmoderator, escrowmoderatorfee ,now); emit NewEscrowEventById(esid, msg.sender, escrowpayee, escrowamount, escrowmoderator, escrowmoderatorfee, now); } modifier onlyPayerOrModerator(bytes32 esid) { require(msg.sender == Escrows[esid].escrowpayer || msg.sender == Escrows[esid].escrowmoderator, "Only Payer or Moderator"); _; } modifier onlyPayeeOrModerator(bytes32 esid) { require(msg.sender == Escrows[esid].escrowpayee || msg.sender == Escrows[esid].escrowmoderator, "Only Payee or Moderator"); _; } function getEscrowDetails(bytes32 esid) external view returns (escrowstatus, uint) { /* Gets the changing variables of a escrow based on escrowid */ Escrow memory thisescrow = Escrows[esid]; require(thisescrow.escrowpayee !=address(0),"Escrow does not exist"); return(thisescrow.estatus, thisescrow.escrowsettlementamount); } function setEscrowSettlementAmount(bytes32 esid, uint esettlementamount) external onlyPayeeOrModerator(esid) { /* Only the escrow Payee or Moderator can change the escrow settlement amount to less than or equal to the original escrowamount */ Escrow storage thisescrow = Escrows[esid]; require(thisescrow.estatus == escrowstatus.ACTIVATED,"Escrow should be Activated"); require(esettlementamount > 0 && esettlementamount <= thisescrow.escrowamount ,"escrow settlementamount is incorrect"); thisescrow.escrowsettlementamount = esettlementamount; emit EscrowStatusEvent(esid, thisescrow.estatus, thisescrow.escrowsettlementamount,now); } function releaseFundsToPayee(bytes32 esid) external onlyPayerOrModerator(esid) { /* 1) The payee gets paid the escrow settlement amount 2) The moderator gets paid the moderation fee if exists 3) Any remaining amount is transferred to the Payer */ Escrow storage thisescrow = Escrows[esid]; require(thisescrow.estatus == escrowstatus.ACTIVATED, "Escrow Should be activated"); require(thisescrow.escrowsettlementamount > 0, "Escrow Settlement amount is 0"); uint payeramt = thisescrow.escrowamount > thisescrow.escrowsettlementamount ? mathlib.sub(thisescrow.escrowamount,thisescrow.escrowsettlementamount) : 0; uint settlementamount = thisescrow.escrowsettlementamount; thisescrow.escrowsettlementamount = 0; thisescrow.estatus = escrowstatus.SETTLED; //Payee gets paid daiToken.transfer(thisescrow.escrowpayee,settlementamount); //Moderator gets paid if exists if (thisescrow.escrowmoderatorfee > 0) { daiToken.transfer(thisescrow.escrowmoderator,thisescrow.escrowmoderatorfee); } //Payer gets paid any remaining balance if (payeramt > 0) { daiToken.transfer(thisescrow.escrowpayer,payeramt); } emit EscrowStatusEvent(esid, thisescrow.estatus, thisescrow.escrowsettlementamount,now); } function cancelEscrow(bytes32 esid) external onlyPayeeOrModerator(esid) { /* 1) The payer gets refunded the full escrow amount 2) The moderator gets paid the moderation fee if exists */ Escrow storage thisescrow = Escrows[esid]; require(thisescrow.estatus == escrowstatus.ACTIVATED, "Escrow Should be activated"); require(thisescrow.escrowamount == thisescrow.escrowsettlementamount,"Escrow amount and Escrow settlement amount should be equal"); uint settlementamount = thisescrow.escrowsettlementamount; thisescrow.escrowsettlementamount = 0; thisescrow.estatus = escrowstatus.CANCELLED; //Moderator gets paid if exists if (thisescrow.escrowmoderatorfee > 0) { daiToken.transfer(thisescrow.escrowmoderator,thisescrow.escrowmoderatorfee); } //Payer gets full refund daiToken.transfer(thisescrow.escrowpayer,settlementamount); emit EscrowStatusEvent(esid, thisescrow.estatus, thisescrow.escrowsettlementamount,now); } }
createNewEscrow
function createNewEscrow(address escrowpayee, uint escrowamount) external { require(factorycontractactive, "Factory Contract should be Active"); require(escrowid < maxuint, "Maximum escrowid reached"); require(msg.sender != escrowpayee,"The Payer, payee should be different"); require(escrowpayee != address(0),"The Escrow Payee can not be address(0)"); require(escrowamount > 0,"Escrow amount has to be greater than 0"); require(daiToken.allowance(msg.sender,address(this)) >= mathlib.add(escrowamount, escrowfee), "daiToken allowance exceeded"); bytes32 esid = keccak256(abi.encodePacked(escrowid)); Escrows[esid] = Escrow({escrowpayer:msg.sender, escrowpayee:escrowpayee, escrowamount:escrowamount, escrowsettlementamount:escrowamount, estatus:escrowstatus.ACTIVATED,escrowmoderator:address(0),escrowmoderatorfee:0}); escrowid = mathlib.add(escrowid,1); //The Esrow Amount gets transferred to factory contract daiToken.transferFrom(msg.sender, address(this), escrowamount); //Transfer the escrow fee to factory manager daiToken.transferFrom(msg.sender, manager, escrowfee); emit NewEscrowEvent(esid, msg.sender, escrowpayee, escrowamount, now); emit NewEscrowEventById(esid, msg.sender, escrowpayee, escrowamount, now); }
//create new escrow
LineComment
v0.6.12+commit.27d51765
GNU GPLv3
ipfs://b80b0d3a2f6700979825fe5f689f9982ac6146fbc93c527521f6eebb19e80b32
{ "func_code_index": [ 2936, 4395 ] }
5,600
EscrowFactory
stableescrow.sol
0xd03a329e6a1f05d0c797215a82e8f0e14f241d4b
Solidity
EscrowFactory
contract EscrowFactory is owned { /* 1) The Escrow Factory contract to create and manage Escrows 2) Only the Escrow Factory is owned by the manager 3) The manager has no control over each Escrow or the cumulative payment locked in the Factory contract */ address constant private dai_ = 0x6B175474E89094C44Da98b954EedeAC495271d0F; DaiErc20 constant private daiToken = DaiErc20(dai_); //Escrow Fee in wad payed to the manager to create a Escrow uint public escrowfee; //Switch that controls whether the factory is active bool public factorycontractactive; uint private escrowid; uint constant private maxuint = 2**256-1; struct Escrow { address escrowpayer; address escrowpayee; uint escrowamount; uint escrowsettlementamount; escrowstatus estatus; address escrowmoderator; uint escrowmoderatorfee; } mapping (bytes32 => Escrow) public Escrows; /** Events **/ //Event for new Escrow Contract event NewEscrowEvent(bytes32 esid, address indexed escrowpayer, address indexed escrowpayee, uint escrowamount, uint eventtime); //Event overload with moderator event NewEscrowEvent(bytes32 esid, address indexed escrowpayer, address indexed escrowpayee, uint escrowamount, address indexed escrowmoderator, uint escrowmoderatorfee, uint eventtime); //The Escrowid is indexed event NewEscrowEventById(bytes32 indexed esid, address escrowpayer, address escrowpayee, uint escrowamount, uint eventtime); //The Escrowid is indexed overload for moderator event NewEscrowEventById(bytes32 indexed esid, address escrowpayer, address escrowpayee, uint escrowamount, address escrowmoderator, uint escrowmoderatorfee, uint eventtime); //Escrow Status Change Event event EscrowStatusEvent(bytes32 indexed esid, escrowstatus estatus, uint escrowsettlementamount, uint eventtime); constructor() public { escrowid = 0; escrowfee = 1000000000000000000; //1 DAI factorycontractactive = true; } function setEscrowFee(uint newfee) external onlyManager { /* 1) Changes the Escrow fee that is paid to the manager 2) The Escrow fee at launch of contract is set to 1 DAI 3) The escrowfee is a public variable and can always queried */ require(newfee > 0); escrowfee = newfee; } function setFactoryContractSwitch() external onlyManager { /* 1) Switch that controls whether the contract is active 2) If the contract is paused new Escrows can not be created, but existing Escrows can still be Settled. */ factorycontractactive = factorycontractactive == true ? false : true; } //create new escrow function createNewEscrow(address escrowpayee, uint escrowamount) external { require(factorycontractactive, "Factory Contract should be Active"); require(escrowid < maxuint, "Maximum escrowid reached"); require(msg.sender != escrowpayee,"The Payer, payee should be different"); require(escrowpayee != address(0),"The Escrow Payee can not be address(0)"); require(escrowamount > 0,"Escrow amount has to be greater than 0"); require(daiToken.allowance(msg.sender,address(this)) >= mathlib.add(escrowamount, escrowfee), "daiToken allowance exceeded"); bytes32 esid = keccak256(abi.encodePacked(escrowid)); Escrows[esid] = Escrow({escrowpayer:msg.sender, escrowpayee:escrowpayee, escrowamount:escrowamount, escrowsettlementamount:escrowamount, estatus:escrowstatus.ACTIVATED,escrowmoderator:address(0),escrowmoderatorfee:0}); escrowid = mathlib.add(escrowid,1); //The Esrow Amount gets transferred to factory contract daiToken.transferFrom(msg.sender, address(this), escrowamount); //Transfer the escrow fee to factory manager daiToken.transferFrom(msg.sender, manager, escrowfee); emit NewEscrowEvent(esid, msg.sender, escrowpayee, escrowamount, now); emit NewEscrowEventById(esid, msg.sender, escrowpayee, escrowamount, now); } //create new escrow overload function createNewEscrow(address escrowpayee, uint escrowamount, address escrowmoderator, uint escrowmoderatorfee) external { require(factorycontractactive, "Factory Contract should be Active"); require(escrowid < maxuint, "Maximum escrowid reached"); require(msg.sender != escrowpayee && msg.sender != escrowmoderator && escrowpayee != escrowmoderator,"The Payer, payee & moderator should be different"); require(escrowpayee != address(0) && escrowmoderator!=address(0),"Escrow Payee or moderator can not be address(0)"); require(escrowamount > 0,"Escrow amount has to be greater than 0"); uint dailockedinnewescrow = mathlib.add(escrowamount,escrowmoderatorfee); require(daiToken.allowance(msg.sender,address(this)) >= mathlib.add(dailockedinnewescrow, escrowfee), "daiToken allowance exceeded"); bytes32 esid = keccak256(abi.encodePacked(escrowid)); Escrows[esid] = Escrows[esid] = Escrow({escrowpayer:msg.sender, escrowpayee:escrowpayee, escrowamount:escrowamount, escrowsettlementamount:escrowamount, estatus:escrowstatus.ACTIVATED,escrowmoderator:escrowmoderator,escrowmoderatorfee:escrowmoderatorfee}); escrowid = mathlib.add(escrowid,1); //The Esrow Amount and Moderator fee gets transferred to factory contract daiToken.transferFrom(msg.sender, address(this), dailockedinnewescrow); //Transfer the escrow fee to factory manager daiToken.transferFrom(msg.sender, manager, escrowfee); emit NewEscrowEvent(esid, msg.sender, escrowpayee, escrowamount, escrowmoderator, escrowmoderatorfee ,now); emit NewEscrowEventById(esid, msg.sender, escrowpayee, escrowamount, escrowmoderator, escrowmoderatorfee, now); } modifier onlyPayerOrModerator(bytes32 esid) { require(msg.sender == Escrows[esid].escrowpayer || msg.sender == Escrows[esid].escrowmoderator, "Only Payer or Moderator"); _; } modifier onlyPayeeOrModerator(bytes32 esid) { require(msg.sender == Escrows[esid].escrowpayee || msg.sender == Escrows[esid].escrowmoderator, "Only Payee or Moderator"); _; } function getEscrowDetails(bytes32 esid) external view returns (escrowstatus, uint) { /* Gets the changing variables of a escrow based on escrowid */ Escrow memory thisescrow = Escrows[esid]; require(thisescrow.escrowpayee !=address(0),"Escrow does not exist"); return(thisescrow.estatus, thisescrow.escrowsettlementamount); } function setEscrowSettlementAmount(bytes32 esid, uint esettlementamount) external onlyPayeeOrModerator(esid) { /* Only the escrow Payee or Moderator can change the escrow settlement amount to less than or equal to the original escrowamount */ Escrow storage thisescrow = Escrows[esid]; require(thisescrow.estatus == escrowstatus.ACTIVATED,"Escrow should be Activated"); require(esettlementamount > 0 && esettlementamount <= thisescrow.escrowamount ,"escrow settlementamount is incorrect"); thisescrow.escrowsettlementamount = esettlementamount; emit EscrowStatusEvent(esid, thisescrow.estatus, thisescrow.escrowsettlementamount,now); } function releaseFundsToPayee(bytes32 esid) external onlyPayerOrModerator(esid) { /* 1) The payee gets paid the escrow settlement amount 2) The moderator gets paid the moderation fee if exists 3) Any remaining amount is transferred to the Payer */ Escrow storage thisescrow = Escrows[esid]; require(thisescrow.estatus == escrowstatus.ACTIVATED, "Escrow Should be activated"); require(thisescrow.escrowsettlementamount > 0, "Escrow Settlement amount is 0"); uint payeramt = thisescrow.escrowamount > thisescrow.escrowsettlementamount ? mathlib.sub(thisescrow.escrowamount,thisescrow.escrowsettlementamount) : 0; uint settlementamount = thisescrow.escrowsettlementamount; thisescrow.escrowsettlementamount = 0; thisescrow.estatus = escrowstatus.SETTLED; //Payee gets paid daiToken.transfer(thisescrow.escrowpayee,settlementamount); //Moderator gets paid if exists if (thisescrow.escrowmoderatorfee > 0) { daiToken.transfer(thisescrow.escrowmoderator,thisescrow.escrowmoderatorfee); } //Payer gets paid any remaining balance if (payeramt > 0) { daiToken.transfer(thisescrow.escrowpayer,payeramt); } emit EscrowStatusEvent(esid, thisescrow.estatus, thisescrow.escrowsettlementamount,now); } function cancelEscrow(bytes32 esid) external onlyPayeeOrModerator(esid) { /* 1) The payer gets refunded the full escrow amount 2) The moderator gets paid the moderation fee if exists */ Escrow storage thisescrow = Escrows[esid]; require(thisescrow.estatus == escrowstatus.ACTIVATED, "Escrow Should be activated"); require(thisescrow.escrowamount == thisescrow.escrowsettlementamount,"Escrow amount and Escrow settlement amount should be equal"); uint settlementamount = thisescrow.escrowsettlementamount; thisescrow.escrowsettlementamount = 0; thisescrow.estatus = escrowstatus.CANCELLED; //Moderator gets paid if exists if (thisescrow.escrowmoderatorfee > 0) { daiToken.transfer(thisescrow.escrowmoderator,thisescrow.escrowmoderatorfee); } //Payer gets full refund daiToken.transfer(thisescrow.escrowpayer,settlementamount); emit EscrowStatusEvent(esid, thisescrow.estatus, thisescrow.escrowsettlementamount,now); } }
createNewEscrow
function createNewEscrow(address escrowpayee, uint escrowamount, address escrowmoderator, uint escrowmoderatorfee) external { require(factorycontractactive, "Factory Contract should be Active"); require(escrowid < maxuint, "Maximum escrowid reached"); require(msg.sender != escrowpayee && msg.sender != escrowmoderator && escrowpayee != escrowmoderator,"The Payer, payee & moderator should be different"); require(escrowpayee != address(0) && escrowmoderator!=address(0),"Escrow Payee or moderator can not be address(0)"); require(escrowamount > 0,"Escrow amount has to be greater than 0"); uint dailockedinnewescrow = mathlib.add(escrowamount,escrowmoderatorfee); require(daiToken.allowance(msg.sender,address(this)) >= mathlib.add(dailockedinnewescrow, escrowfee), "daiToken allowance exceeded"); bytes32 esid = keccak256(abi.encodePacked(escrowid)); Escrows[esid] = Escrows[esid] = Escrow({escrowpayer:msg.sender, escrowpayee:escrowpayee, escrowamount:escrowamount, escrowsettlementamount:escrowamount, estatus:escrowstatus.ACTIVATED,escrowmoderator:escrowmoderator,escrowmoderatorfee:escrowmoderatorfee}); escrowid = mathlib.add(escrowid,1); //The Esrow Amount and Moderator fee gets transferred to factory contract daiToken.transferFrom(msg.sender, address(this), dailockedinnewescrow); //Transfer the escrow fee to factory manager daiToken.transferFrom(msg.sender, manager, escrowfee); emit NewEscrowEvent(esid, msg.sender, escrowpayee, escrowamount, escrowmoderator, escrowmoderatorfee ,now); emit NewEscrowEventById(esid, msg.sender, escrowpayee, escrowamount, escrowmoderator, escrowmoderatorfee, now); }
//create new escrow overload
LineComment
v0.6.12+commit.27d51765
GNU GPLv3
ipfs://b80b0d3a2f6700979825fe5f689f9982ac6146fbc93c527521f6eebb19e80b32
{ "func_code_index": [ 4435, 6290 ] }
5,601
FlashLiquidator
@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol
0x23d85060f87218bb276afe55a26bfd3b5f59914e
Solidity
ISwapRouter
interface ISwapRouter is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
/// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3
NatSpecSingleLine
exactInputSingle
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
/// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token
NatSpecSingleLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 567, 682 ] }
5,602
FlashLiquidator
@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol
0x23d85060f87218bb276afe55a26bfd3b5f59914e
Solidity
ISwapRouter
interface ISwapRouter is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
/// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3
NatSpecSingleLine
exactInput
function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);
/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token
NatSpecSingleLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 1132, 1235 ] }
5,603
FlashLiquidator
@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol
0x23d85060f87218bb276afe55a26bfd3b5f59914e
Solidity
ISwapRouter
interface ISwapRouter is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
/// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3
NatSpecSingleLine
exactOutputSingle
function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);
/// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token
NatSpecSingleLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 1755, 1871 ] }
5,604
FlashLiquidator
@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol
0x23d85060f87218bb276afe55a26bfd3b5f59914e
Solidity
ISwapRouter
interface ISwapRouter is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
/// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3
NatSpecSingleLine
exactOutput
function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
/// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token
NatSpecSingleLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 2333, 2437 ] }
5,605
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
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; } /** * @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) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; }
/** * @dev Multiplies two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 89, 266 ] }
5,606
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
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; } /** * @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.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 350, 630 ] }
5,607
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
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; } /** * @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.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 744, 860 ] }
5,608
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
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; } /** * @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.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 924, 1054 ] }
5,609
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
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.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 199, 287 ] }
5,610
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
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.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 445, 777 ] }
5,611
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
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.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 983, 1087 ] }
5,612
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; }
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */
NatSpecMultiLine
v0.4.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 401, 858 ] }
5,613
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
approve
function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
/** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */
NatSpecMultiLine
v0.4.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 1490, 1685 ] }
5,614
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
allowance
function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; }
/** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */
NatSpecMultiLine
v0.4.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 2009, 2140 ] }
5,615
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
increaseApproval
function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
/** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */
NatSpecMultiLine
v0.4.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 2606, 2875 ] }
5,616
KuoMingToken
KuoMingToken.sol
0x284764679123e3aa1f460c4498b7dbd666067b9d
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
decreaseApproval
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
/** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */
NatSpecMultiLine
v0.4.23+commit.124ca40d
bzzr://881fc6a7358e7998351f0354065999a0fa6f410ef62be1c5310660ae0153a285
{ "func_code_index": [ 3346, 3761 ] }
5,617
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the amount of tokens in existence. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 94, 154 ] }
5,618
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
balanceOf
function balanceOf(address account) external view returns (uint256);
/** * @dev Returns the amount of tokens owned by `account`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 237, 310 ] }
5,619
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
transfer
function transfer(address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 534, 616 ] }
5,620
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
allowance
function allowance(address owner, address spender) external view returns (uint256);
/** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 895, 983 ] }
5,621
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
approve
function approve(address spender, uint256 amount) external returns (bool);
/** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 1647, 1726 ] }
5,622
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
transferFrom
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 2039, 2141 ] }
5,623
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; }
/** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 259, 445 ] }
5,624
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); }
/** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 723, 864 ] }
5,625
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
sub
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; }
/** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 1162, 1359 ] }
5,626
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; }
/** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 1613, 2089 ] }
5,627
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); }
/** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 2560, 2697 ] }
5,628
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
div
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 3188, 3471 ] }
5,629
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 3931, 4066 ] }
5,630
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
mod
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 4546, 4717 ] }
5,631
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
isContract
function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); }
/** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 606, 1230 ] }
5,632
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
sendValue
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); }
/** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 2160, 2562 ] }
5,633
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
functionCall
function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); }
/** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 3318, 3496 ] }
5,634
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
functionCall
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 3721, 3922 ] }
5,635
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
functionCallWithValue
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 4292, 4523 ] }
5,636
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
functionCallWithValue
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); }
/** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 4774, 5095 ] }
5,637
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
Ownable
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
owner
function owner() public view returns (address) { return _owner; }
/** * @dev Returns the address of the current owner. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 497, 581 ] }
5,638
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
Ownable
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
renounceOwnership
function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); }
/** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 1139, 1292 ] }
5,639
ShepFinance
ShepFinance.sol
0xe1922512914fa1b1309dfedbbdef3836b0abdcb9
Solidity
Ownable
contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
transferOwnership
function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; }
/** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ff13e9810158404af4492daa91fb38bc7c3fd38c7cc61f343a491fd44f6343ba
{ "func_code_index": [ 1442, 1691 ] }
5,640
FlashLiquidator
@uniswap/v3-periphery/contracts/base/PeripheryPayments.sol
0x23d85060f87218bb276afe55a26bfd3b5f59914e
Solidity
PeripheryPayments
abstract contract PeripheryPayments is IPeripheryPayments, PeripheryImmutableState { receive() external payable { require(msg.sender == WETH9, 'Not WETH9'); } /// @inheritdoc IPeripheryPayments function unwrapWETH9(uint256 amountMinimum, address recipient) external payable override { uint256 balanceWETH9 = IWETH9(WETH9).balanceOf(address(this)); require(balanceWETH9 >= amountMinimum, 'Insufficient WETH9'); if (balanceWETH9 > 0) { IWETH9(WETH9).withdraw(balanceWETH9); TransferHelper.safeTransferETH(recipient, balanceWETH9); } } /// @inheritdoc IPeripheryPayments function sweepToken( address token, uint256 amountMinimum, address recipient ) external payable override { uint256 balanceToken = IERC20(token).balanceOf(address(this)); require(balanceToken >= amountMinimum, 'Insufficient token'); if (balanceToken > 0) { TransferHelper.safeTransfer(token, recipient, balanceToken); } } /// @inheritdoc IPeripheryPayments function refundETH() external payable override { if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance); } /// @param token The token to pay /// @param payer The entity that must pay /// @param recipient The entity that will receive payment /// @param value The amount to pay function pay( address token, address payer, address recipient, uint256 value ) internal { if (token == WETH9 && address(this).balance >= value) { // pay with WETH9 IWETH9(WETH9).deposit{value: value}(); // wrap only what is needed to pay IWETH9(WETH9).transfer(recipient, value); } else if (payer == address(this)) { // pay with tokens already in the contract (for the exact input multihop case) TransferHelper.safeTransfer(token, recipient, value); } else { // pull payment TransferHelper.safeTransferFrom(token, payer, recipient, value); } } }
//
LineComment
unwrapWETH9
function unwrapWETH9(uint256 amountMinimum, address recipient) external payable override { uint256 balanceWETH9 = IWETH9(WETH9).balanceOf(address(this)); require(balanceWETH9 >= amountMinimum, 'Insufficient WETH9'); if (balanceWETH9 > 0) { IWETH9(WETH9).withdraw(balanceWETH9); TransferHelper.safeTransferETH(recipient, balanceWETH9); } }
/// @inheritdoc IPeripheryPayments
NatSpecSingleLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 215, 618 ] }
5,641
FlashLiquidator
@uniswap/v3-periphery/contracts/base/PeripheryPayments.sol
0x23d85060f87218bb276afe55a26bfd3b5f59914e
Solidity
PeripheryPayments
abstract contract PeripheryPayments is IPeripheryPayments, PeripheryImmutableState { receive() external payable { require(msg.sender == WETH9, 'Not WETH9'); } /// @inheritdoc IPeripheryPayments function unwrapWETH9(uint256 amountMinimum, address recipient) external payable override { uint256 balanceWETH9 = IWETH9(WETH9).balanceOf(address(this)); require(balanceWETH9 >= amountMinimum, 'Insufficient WETH9'); if (balanceWETH9 > 0) { IWETH9(WETH9).withdraw(balanceWETH9); TransferHelper.safeTransferETH(recipient, balanceWETH9); } } /// @inheritdoc IPeripheryPayments function sweepToken( address token, uint256 amountMinimum, address recipient ) external payable override { uint256 balanceToken = IERC20(token).balanceOf(address(this)); require(balanceToken >= amountMinimum, 'Insufficient token'); if (balanceToken > 0) { TransferHelper.safeTransfer(token, recipient, balanceToken); } } /// @inheritdoc IPeripheryPayments function refundETH() external payable override { if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance); } /// @param token The token to pay /// @param payer The entity that must pay /// @param recipient The entity that will receive payment /// @param value The amount to pay function pay( address token, address payer, address recipient, uint256 value ) internal { if (token == WETH9 && address(this).balance >= value) { // pay with WETH9 IWETH9(WETH9).deposit{value: value}(); // wrap only what is needed to pay IWETH9(WETH9).transfer(recipient, value); } else if (payer == address(this)) { // pay with tokens already in the contract (for the exact input multihop case) TransferHelper.safeTransfer(token, recipient, value); } else { // pull payment TransferHelper.safeTransferFrom(token, payer, recipient, value); } } }
//
LineComment
sweepToken
function sweepToken( address token, uint256 amountMinimum, address recipient ) external payable override { uint256 balanceToken = IERC20(token).balanceOf(address(this)); require(balanceToken >= amountMinimum, 'Insufficient token'); if (balanceToken > 0) { TransferHelper.safeTransfer(token, recipient, balanceToken); } }
/// @inheritdoc IPeripheryPayments
NatSpecSingleLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 659, 1060 ] }
5,642
FlashLiquidator
@uniswap/v3-periphery/contracts/base/PeripheryPayments.sol
0x23d85060f87218bb276afe55a26bfd3b5f59914e
Solidity
PeripheryPayments
abstract contract PeripheryPayments is IPeripheryPayments, PeripheryImmutableState { receive() external payable { require(msg.sender == WETH9, 'Not WETH9'); } /// @inheritdoc IPeripheryPayments function unwrapWETH9(uint256 amountMinimum, address recipient) external payable override { uint256 balanceWETH9 = IWETH9(WETH9).balanceOf(address(this)); require(balanceWETH9 >= amountMinimum, 'Insufficient WETH9'); if (balanceWETH9 > 0) { IWETH9(WETH9).withdraw(balanceWETH9); TransferHelper.safeTransferETH(recipient, balanceWETH9); } } /// @inheritdoc IPeripheryPayments function sweepToken( address token, uint256 amountMinimum, address recipient ) external payable override { uint256 balanceToken = IERC20(token).balanceOf(address(this)); require(balanceToken >= amountMinimum, 'Insufficient token'); if (balanceToken > 0) { TransferHelper.safeTransfer(token, recipient, balanceToken); } } /// @inheritdoc IPeripheryPayments function refundETH() external payable override { if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance); } /// @param token The token to pay /// @param payer The entity that must pay /// @param recipient The entity that will receive payment /// @param value The amount to pay function pay( address token, address payer, address recipient, uint256 value ) internal { if (token == WETH9 && address(this).balance >= value) { // pay with WETH9 IWETH9(WETH9).deposit{value: value}(); // wrap only what is needed to pay IWETH9(WETH9).transfer(recipient, value); } else if (payer == address(this)) { // pay with tokens already in the contract (for the exact input multihop case) TransferHelper.safeTransfer(token, recipient, value); } else { // pull payment TransferHelper.safeTransferFrom(token, payer, recipient, value); } } }
//
LineComment
refundETH
function refundETH() external payable override { if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance); }
/// @inheritdoc IPeripheryPayments
NatSpecSingleLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 1101, 1265 ] }
5,643
FlashLiquidator
@uniswap/v3-periphery/contracts/base/PeripheryPayments.sol
0x23d85060f87218bb276afe55a26bfd3b5f59914e
Solidity
PeripheryPayments
abstract contract PeripheryPayments is IPeripheryPayments, PeripheryImmutableState { receive() external payable { require(msg.sender == WETH9, 'Not WETH9'); } /// @inheritdoc IPeripheryPayments function unwrapWETH9(uint256 amountMinimum, address recipient) external payable override { uint256 balanceWETH9 = IWETH9(WETH9).balanceOf(address(this)); require(balanceWETH9 >= amountMinimum, 'Insufficient WETH9'); if (balanceWETH9 > 0) { IWETH9(WETH9).withdraw(balanceWETH9); TransferHelper.safeTransferETH(recipient, balanceWETH9); } } /// @inheritdoc IPeripheryPayments function sweepToken( address token, uint256 amountMinimum, address recipient ) external payable override { uint256 balanceToken = IERC20(token).balanceOf(address(this)); require(balanceToken >= amountMinimum, 'Insufficient token'); if (balanceToken > 0) { TransferHelper.safeTransfer(token, recipient, balanceToken); } } /// @inheritdoc IPeripheryPayments function refundETH() external payable override { if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance); } /// @param token The token to pay /// @param payer The entity that must pay /// @param recipient The entity that will receive payment /// @param value The amount to pay function pay( address token, address payer, address recipient, uint256 value ) internal { if (token == WETH9 && address(this).balance >= value) { // pay with WETH9 IWETH9(WETH9).deposit{value: value}(); // wrap only what is needed to pay IWETH9(WETH9).transfer(recipient, value); } else if (payer == address(this)) { // pay with tokens already in the contract (for the exact input multihop case) TransferHelper.safeTransfer(token, recipient, value); } else { // pull payment TransferHelper.safeTransferFrom(token, payer, recipient, value); } } }
//
LineComment
pay
function pay( address token, address payer, address recipient, uint256 value ) internal { if (token == WETH9 && address(this).balance >= value) { // pay with WETH9 IWETH9(WETH9).deposit{value: value}(); // wrap only what is needed to pay IWETH9(WETH9).transfer(recipient, value); } else if (payer == address(this)) { // pay with tokens already in the contract (for the exact input multihop case) TransferHelper.safeTransfer(token, recipient, value); } else { // pull payment TransferHelper.safeTransferFrom(token, payer, recipient, value); } }
/// @param token The token to pay /// @param payer The entity that must pay /// @param recipient The entity that will receive payment /// @param value The amount to pay
NatSpecSingleLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 1452, 2155 ] }
5,644
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC165
interface ERC165 { /** * @notice Query if a contract implements an interface * @param _interfaceId The interface identifier, as specified in ERC-165 * @dev Interface identification is specified in ERC-165. This function * uses less than 30,000 gas. */ function supportsInterface(bytes4 _interfaceId) external view returns (bool); }
/** * @title ERC165 * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md */
NatSpecMultiLine
supportsInterface
function supportsInterface(bytes4 _interfaceId) external view returns (bool);
/** * @notice Query if a contract implements an interface * @param _interfaceId The interface identifier, as specified in ERC-165 * @dev Interface identification is specified in ERC-165. This function * uses less than 30,000 gas. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 278, 373 ] }
5,645
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721Receiver
interface ERC721Receiver { /** * @dev Magic value to be returned upon successful reception of an NFT * Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`, * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` */ // bytes4 internal constant ERC721_RECEIVED = 0x150b7a02; /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a `safetransfer`. This function MAY throw to revert and reject the * transfer. Return of other than the magic value MUST result in the * transaction being reverted. * Note: the contract address is always the message sender. * @param _operator The address which called `safeTransferFrom` function * @param _from The address which previously owned the token * @param _tokenId The NFT identifier which is being transferred * @param _data Additional data with no specified format * @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received( address _operator, address _from, uint256 _tokenId, bytes memory _data ) external returns(bytes4); }
/** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */
NatSpecMultiLine
onERC721Received
function onERC721Received( address _operator, address _from, uint256 _tokenId, bytes memory _data ) external returns(bytes4);
/** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a `safetransfer`. This function MAY throw to revert and reject the * transfer. Return of other than the magic value MUST result in the * transaction being reverted. * Note: the contract address is always the message sender. * @param _operator The address which called `safeTransferFrom` function * @param _from The address which previously owned the token * @param _tokenId The NFT identifier which is being transferred * @param _data Additional data with no specified format * @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 1087, 1240 ] }
5,646
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
AddressUtils
library AddressUtils { /** * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param _addr address to check * @return whether the target address is a contract */ function isContract(address _addr) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(_addr) } return size > 0; } }
/** * Utility library of inline functions on addresses */
NatSpecMultiLine
isContract
function isContract(address _addr) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(_addr) } return size > 0; }
/** * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param _addr address to check * @return whether the target address is a contract */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 358, 950 ] }
5,647
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
SupportsInterfaceWithLookup
contract SupportsInterfaceWithLookup is ERC165 { bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7; /** * 0x01ffc9a7 === * bytes4(keccak256('supportsInterface(bytes4)')) */ /** * @dev a mapping of interface id to whether or not it's supported */ mapping(bytes4 => bool) internal supportedInterfaces; /** * @dev A contract implementing SupportsInterfaceWithLookup * implement ERC165 itself */ constructor() public { _registerInterface(InterfaceId_ERC165); } /** * @dev implement supportsInterface(bytes4) using a lookup table */ function supportsInterface(bytes4 _interfaceId) external override view returns (bool) { return supportedInterfaces[_interfaceId]; } /** * @dev private method for registering an interface */ function _registerInterface(bytes4 _interfaceId) internal { require(_interfaceId != 0xffffffff); supportedInterfaces[_interfaceId] = true; } }
/** * @title SupportsInterfaceWithLookup * @author Matt Condon (@shrugs) * @dev Implements ERC165 using a lookup table. */
NatSpecMultiLine
supportsInterface
function supportsInterface(bytes4 _interfaceId) external override view returns (bool) { return supportedInterfaces[_interfaceId]; }
/** * @dev implement supportsInterface(bytes4) using a lookup table */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 621, 786 ] }
5,648
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
SupportsInterfaceWithLookup
contract SupportsInterfaceWithLookup is ERC165 { bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7; /** * 0x01ffc9a7 === * bytes4(keccak256('supportsInterface(bytes4)')) */ /** * @dev a mapping of interface id to whether or not it's supported */ mapping(bytes4 => bool) internal supportedInterfaces; /** * @dev A contract implementing SupportsInterfaceWithLookup * implement ERC165 itself */ constructor() public { _registerInterface(InterfaceId_ERC165); } /** * @dev implement supportsInterface(bytes4) using a lookup table */ function supportsInterface(bytes4 _interfaceId) external override view returns (bool) { return supportedInterfaces[_interfaceId]; } /** * @dev private method for registering an interface */ function _registerInterface(bytes4 _interfaceId) internal { require(_interfaceId != 0xffffffff); supportedInterfaces[_interfaceId] = true; } }
/** * @title SupportsInterfaceWithLookup * @author Matt Condon (@shrugs) * @dev Implements ERC165 using a lookup table. */
NatSpecMultiLine
_registerInterface
function _registerInterface(bytes4 _interfaceId) internal { require(_interfaceId != 0xffffffff); supportedInterfaces[_interfaceId] = true; }
/** * @dev private method for registering an interface */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 858, 1022 ] }
5,649
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
IERC721Enumerable
interface IERC721Enumerable is ERC721Basic { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); }
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the total amount of tokens stored by the contract. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 138, 198 ] }
5,650
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
balanceOf
function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; }
/* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */
Comment
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 2517, 2674 ] }
5,651
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
ownerOf
function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; }
/** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 2891, 3071 ] }
5,652
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
exists
function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); }
/* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */
Comment
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 3252, 3407 ] }
5,653
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
approve
function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); }
/** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 3819, 4115 ] }
5,654
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
getApproved
function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; }
/** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 4346, 4471 ] }
5,655
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
setApprovalForAll
function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); }
/** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 4756, 4977 ] }
5,656
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
isApprovedForAll
function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; }
/** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 5291, 5485 ] }
5,657
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
transferFrom
function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); }
/** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 5910, 6313 ] }
5,658
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
safeTransferFrom
function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); }
/** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 6940, 7165 ] }
5,659
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
safeTransferFrom
function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); }
/** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 7858, 8169 ] }
5,660
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
isApprovedOrOwner
function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); }
/** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 8522, 8980 ] }
5,661
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
_mint
function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); }
/** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 9234, 9418 ] }
5,662
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
_burn
function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); }
/** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 9608, 9811 ] }
5,663
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
clearApproval
function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } }
/** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 10078, 10300 ] }
5,664
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
addTokenTo
function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); }
/** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 10567, 10786 ] }
5,665
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
removeTokenFrom
function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); }
/** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 11069, 11298 ] }
5,666
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
ERC721BasicToken
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ * bytes4(keccak256('ownerOf(uint256)')) ^ * bytes4(keccak256('approve(address,uint256)')) ^ * bytes4(keccak256('getApproved(uint256)')) ^ * bytes4(keccak256('setApprovalForAll(address,bool)')) ^ * bytes4(keccak256('isApprovedForAll(address,address)')) ^ * bytes4(keccak256('transferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^ * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) */ bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /* * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /* * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /* * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view override returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /* * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view override returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) override public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view override returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) override public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view override returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public override { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public override { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes memory _data ) override public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function _mint(address _to, uint256 _tokenId) virtual internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) virtual internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address * @param _to address representing the new owner of the given token ID * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address */ function addTokenTo(address _to, uint256 _tokenId) virtual internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address * @param _from address representing the previous owner of the given token ID * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function removeTokenFrom(address _from, uint256 _tokenId) virtual internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } }
/** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */
NatSpecMultiLine
checkAndCallSafeTransfer
function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes memory _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); }
/** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 11812, 12184 ] }
5,667
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
MyERC721Metadata
contract MyERC721Metadata is ERC165, ERC721BasicToken, Owned { // Token name string private _name; // Token symbol string private _symbol; uint256 public _max_supply; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; string public baseURI = "http://nft.huainanhui.com/tokenId/"; /** * @dev Constructor function */ constructor (string memory name, string memory symbol, uint256 maxSupply) public { initOwned(msg.sender); _name = name; _symbol = symbol; _max_supply = maxSupply; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721_METADATA); } function uintToBytes(uint256 num) internal pure returns (bytes memory b) { if (num == 0) { b = new bytes(1); b[0] = byte(uint8(48)); } else { uint256 j = num; uint256 length; while (j != 0) { length++; j /= 10; } b = new bytes(length); uint k = length - 1; while (num != 0) { b[k--] = byte(uint8(48 + num % 10)); num /= 10; } } } function setBaseURI(string memory uri) public onlyOwner { baseURI = uri; } /** * @dev Gets the token name. * @return string representing the token name */ function name() external view returns (string memory) { return _name; } /** * @dev Gets the token symbol. * @return string representing the token symbol */ function symbol() external view returns (string memory) { return _symbol; } function maxSupply() external view returns (uint256) { return _max_supply; } /** * @dev Returns an URI for a given token ID. * Throws if the token ID does not exist. May return an empty string. * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { require(exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory url = _tokenURIs[tokenId]; bytes memory urlAsBytes = bytes(url); if (urlAsBytes.length == 0) { bytes memory baseURIAsBytes = bytes(baseURI); bytes memory tokenIdAsBytes = uintToBytes(tokenId); bytes memory b = new bytes(baseURIAsBytes.length + tokenIdAsBytes.length); uint256 i; uint256 j; for (i = 0; i < baseURIAsBytes.length; i++) { b[j++] = baseURIAsBytes[i]; } for (i = 0; i < tokenIdAsBytes.length; i++) { b[j++] = tokenIdAsBytes[i]; } return string(b); } else { return _tokenURIs[tokenId]; } } /** * @dev Internal function to set the token URI for a given token. * Reverts if the token ID does not exist. * @param tokenId uint256 ID of the token to set its URI * @param uri string URI to assign */ function _setTokenURI(uint256 tokenId, string memory uri) internal { require(exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = uri; } /** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * Deprecated, use _burn(uint256) instead. * @param owner owner of the token to burn * @param tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address owner, uint256 tokenId) override internal { super._burn(owner,tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } }
name
function name() external view returns (string memory) { return _name; }
/** * @dev Gets the token name. * @return string representing the token name */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 1880, 1970 ] }
5,668
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
MyERC721Metadata
contract MyERC721Metadata is ERC165, ERC721BasicToken, Owned { // Token name string private _name; // Token symbol string private _symbol; uint256 public _max_supply; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; string public baseURI = "http://nft.huainanhui.com/tokenId/"; /** * @dev Constructor function */ constructor (string memory name, string memory symbol, uint256 maxSupply) public { initOwned(msg.sender); _name = name; _symbol = symbol; _max_supply = maxSupply; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721_METADATA); } function uintToBytes(uint256 num) internal pure returns (bytes memory b) { if (num == 0) { b = new bytes(1); b[0] = byte(uint8(48)); } else { uint256 j = num; uint256 length; while (j != 0) { length++; j /= 10; } b = new bytes(length); uint k = length - 1; while (num != 0) { b[k--] = byte(uint8(48 + num % 10)); num /= 10; } } } function setBaseURI(string memory uri) public onlyOwner { baseURI = uri; } /** * @dev Gets the token name. * @return string representing the token name */ function name() external view returns (string memory) { return _name; } /** * @dev Gets the token symbol. * @return string representing the token symbol */ function symbol() external view returns (string memory) { return _symbol; } function maxSupply() external view returns (uint256) { return _max_supply; } /** * @dev Returns an URI for a given token ID. * Throws if the token ID does not exist. May return an empty string. * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { require(exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory url = _tokenURIs[tokenId]; bytes memory urlAsBytes = bytes(url); if (urlAsBytes.length == 0) { bytes memory baseURIAsBytes = bytes(baseURI); bytes memory tokenIdAsBytes = uintToBytes(tokenId); bytes memory b = new bytes(baseURIAsBytes.length + tokenIdAsBytes.length); uint256 i; uint256 j; for (i = 0; i < baseURIAsBytes.length; i++) { b[j++] = baseURIAsBytes[i]; } for (i = 0; i < tokenIdAsBytes.length; i++) { b[j++] = tokenIdAsBytes[i]; } return string(b); } else { return _tokenURIs[tokenId]; } } /** * @dev Internal function to set the token URI for a given token. * Reverts if the token ID does not exist. * @param tokenId uint256 ID of the token to set its URI * @param uri string URI to assign */ function _setTokenURI(uint256 tokenId, string memory uri) internal { require(exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = uri; } /** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * Deprecated, use _burn(uint256) instead. * @param owner owner of the token to burn * @param tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address owner, uint256 tokenId) override internal { super._burn(owner,tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } }
symbol
function symbol() external view returns (string memory) { return _symbol; }
/** * @dev Gets the token symbol. * @return string representing the token symbol */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 2080, 2174 ] }
5,669
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
MyERC721Metadata
contract MyERC721Metadata is ERC165, ERC721BasicToken, Owned { // Token name string private _name; // Token symbol string private _symbol; uint256 public _max_supply; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; string public baseURI = "http://nft.huainanhui.com/tokenId/"; /** * @dev Constructor function */ constructor (string memory name, string memory symbol, uint256 maxSupply) public { initOwned(msg.sender); _name = name; _symbol = symbol; _max_supply = maxSupply; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721_METADATA); } function uintToBytes(uint256 num) internal pure returns (bytes memory b) { if (num == 0) { b = new bytes(1); b[0] = byte(uint8(48)); } else { uint256 j = num; uint256 length; while (j != 0) { length++; j /= 10; } b = new bytes(length); uint k = length - 1; while (num != 0) { b[k--] = byte(uint8(48 + num % 10)); num /= 10; } } } function setBaseURI(string memory uri) public onlyOwner { baseURI = uri; } /** * @dev Gets the token name. * @return string representing the token name */ function name() external view returns (string memory) { return _name; } /** * @dev Gets the token symbol. * @return string representing the token symbol */ function symbol() external view returns (string memory) { return _symbol; } function maxSupply() external view returns (uint256) { return _max_supply; } /** * @dev Returns an URI for a given token ID. * Throws if the token ID does not exist. May return an empty string. * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { require(exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory url = _tokenURIs[tokenId]; bytes memory urlAsBytes = bytes(url); if (urlAsBytes.length == 0) { bytes memory baseURIAsBytes = bytes(baseURI); bytes memory tokenIdAsBytes = uintToBytes(tokenId); bytes memory b = new bytes(baseURIAsBytes.length + tokenIdAsBytes.length); uint256 i; uint256 j; for (i = 0; i < baseURIAsBytes.length; i++) { b[j++] = baseURIAsBytes[i]; } for (i = 0; i < tokenIdAsBytes.length; i++) { b[j++] = tokenIdAsBytes[i]; } return string(b); } else { return _tokenURIs[tokenId]; } } /** * @dev Internal function to set the token URI for a given token. * Reverts if the token ID does not exist. * @param tokenId uint256 ID of the token to set its URI * @param uri string URI to assign */ function _setTokenURI(uint256 tokenId, string memory uri) internal { require(exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = uri; } /** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * Deprecated, use _burn(uint256) instead. * @param owner owner of the token to burn * @param tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address owner, uint256 tokenId) override internal { super._burn(owner,tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } }
tokenURI
function tokenURI(uint256 tokenId) external view returns (string memory) { require(exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory url = _tokenURIs[tokenId]; bytes memory urlAsBytes = bytes(url); if (urlAsBytes.length == 0) { bytes memory baseURIAsBytes = bytes(baseURI); bytes memory tokenIdAsBytes = uintToBytes(tokenId); bytes memory b = new bytes(baseURIAsBytes.length + tokenIdAsBytes.length); uint256 i; uint256 j; for (i = 0; i < baseURIAsBytes.length; i++) { b[j++] = baseURIAsBytes[i]; } for (i = 0; i < tokenIdAsBytes.length; i++) { b[j++] = tokenIdAsBytes[i]; } return string(b); } else { return _tokenURIs[tokenId]; } }
/** * @dev Returns an URI for a given token ID. * Throws if the token ID does not exist. May return an empty string. * @param tokenId uint256 ID of the token to query */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 2478, 3385 ] }
5,670
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
MyERC721Metadata
contract MyERC721Metadata is ERC165, ERC721BasicToken, Owned { // Token name string private _name; // Token symbol string private _symbol; uint256 public _max_supply; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; string public baseURI = "http://nft.huainanhui.com/tokenId/"; /** * @dev Constructor function */ constructor (string memory name, string memory symbol, uint256 maxSupply) public { initOwned(msg.sender); _name = name; _symbol = symbol; _max_supply = maxSupply; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721_METADATA); } function uintToBytes(uint256 num) internal pure returns (bytes memory b) { if (num == 0) { b = new bytes(1); b[0] = byte(uint8(48)); } else { uint256 j = num; uint256 length; while (j != 0) { length++; j /= 10; } b = new bytes(length); uint k = length - 1; while (num != 0) { b[k--] = byte(uint8(48 + num % 10)); num /= 10; } } } function setBaseURI(string memory uri) public onlyOwner { baseURI = uri; } /** * @dev Gets the token name. * @return string representing the token name */ function name() external view returns (string memory) { return _name; } /** * @dev Gets the token symbol. * @return string representing the token symbol */ function symbol() external view returns (string memory) { return _symbol; } function maxSupply() external view returns (uint256) { return _max_supply; } /** * @dev Returns an URI for a given token ID. * Throws if the token ID does not exist. May return an empty string. * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { require(exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory url = _tokenURIs[tokenId]; bytes memory urlAsBytes = bytes(url); if (urlAsBytes.length == 0) { bytes memory baseURIAsBytes = bytes(baseURI); bytes memory tokenIdAsBytes = uintToBytes(tokenId); bytes memory b = new bytes(baseURIAsBytes.length + tokenIdAsBytes.length); uint256 i; uint256 j; for (i = 0; i < baseURIAsBytes.length; i++) { b[j++] = baseURIAsBytes[i]; } for (i = 0; i < tokenIdAsBytes.length; i++) { b[j++] = tokenIdAsBytes[i]; } return string(b); } else { return _tokenURIs[tokenId]; } } /** * @dev Internal function to set the token URI for a given token. * Reverts if the token ID does not exist. * @param tokenId uint256 ID of the token to set its URI * @param uri string URI to assign */ function _setTokenURI(uint256 tokenId, string memory uri) internal { require(exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = uri; } /** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * Deprecated, use _burn(uint256) instead. * @param owner owner of the token to burn * @param tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address owner, uint256 tokenId) override internal { super._burn(owner,tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } }
_setTokenURI
function _setTokenURI(uint256 tokenId, string memory uri) internal { require(exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = uri; }
/** * @dev Internal function to set the token URI for a given token. * Reverts if the token ID does not exist. * @param tokenId uint256 ID of the token to set its URI * @param uri string URI to assign */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 3627, 3826 ] }
5,671
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
MyERC721Metadata
contract MyERC721Metadata is ERC165, ERC721BasicToken, Owned { // Token name string private _name; // Token symbol string private _symbol; uint256 public _max_supply; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; string public baseURI = "http://nft.huainanhui.com/tokenId/"; /** * @dev Constructor function */ constructor (string memory name, string memory symbol, uint256 maxSupply) public { initOwned(msg.sender); _name = name; _symbol = symbol; _max_supply = maxSupply; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721_METADATA); } function uintToBytes(uint256 num) internal pure returns (bytes memory b) { if (num == 0) { b = new bytes(1); b[0] = byte(uint8(48)); } else { uint256 j = num; uint256 length; while (j != 0) { length++; j /= 10; } b = new bytes(length); uint k = length - 1; while (num != 0) { b[k--] = byte(uint8(48 + num % 10)); num /= 10; } } } function setBaseURI(string memory uri) public onlyOwner { baseURI = uri; } /** * @dev Gets the token name. * @return string representing the token name */ function name() external view returns (string memory) { return _name; } /** * @dev Gets the token symbol. * @return string representing the token symbol */ function symbol() external view returns (string memory) { return _symbol; } function maxSupply() external view returns (uint256) { return _max_supply; } /** * @dev Returns an URI for a given token ID. * Throws if the token ID does not exist. May return an empty string. * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { require(exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory url = _tokenURIs[tokenId]; bytes memory urlAsBytes = bytes(url); if (urlAsBytes.length == 0) { bytes memory baseURIAsBytes = bytes(baseURI); bytes memory tokenIdAsBytes = uintToBytes(tokenId); bytes memory b = new bytes(baseURIAsBytes.length + tokenIdAsBytes.length); uint256 i; uint256 j; for (i = 0; i < baseURIAsBytes.length; i++) { b[j++] = baseURIAsBytes[i]; } for (i = 0; i < tokenIdAsBytes.length; i++) { b[j++] = tokenIdAsBytes[i]; } return string(b); } else { return _tokenURIs[tokenId]; } } /** * @dev Internal function to set the token URI for a given token. * Reverts if the token ID does not exist. * @param tokenId uint256 ID of the token to set its URI * @param uri string URI to assign */ function _setTokenURI(uint256 tokenId, string memory uri) internal { require(exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = uri; } /** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * Deprecated, use _burn(uint256) instead. * @param owner owner of the token to burn * @param tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address owner, uint256 tokenId) override internal { super._burn(owner,tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } }
_burn
function _burn(address owner, uint256 tokenId) override internal { super._burn(owner,tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } }
/** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * Deprecated, use _burn(uint256) instead. * @param owner owner of the token to burn * @param tokenId uint256 ID of the token being burned by the msg.sender */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 4123, 4383 ] }
5,672
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
CulturalArtTreasure
contract CulturalArtTreasure is MyERC721Metadata,IERC721Enumerable { using Attributes for Attributes.Data; using Attributes for Attributes.Value; using Counters for Counters.Counter; using Accounts for Accounts.Data; using Accounts for Accounts.Account; string public constant TYPE_KEY = "type"; string public constant SUBTYPE_KEY = "subtype"; string public constant NAME_KEY = "name"; string public constant DESCRIPTION_KEY = "description"; string public constant TAGS_KEY = "tags"; mapping(uint256 => Attributes.Data) private attributesByTokenIds; Counters.Counter private _tokenIds; mapping(address => Accounts.Data) private secondaryAccounts; // Duplicated from Attributes for NFT contract ABI to contain events event AttributeAdded(uint256 indexed tokenId, string key, string value, uint totalAfter); event AttributeRemoved(uint256 indexed tokenId, string key, uint totalAfter); event AttributeUpdated(uint256 indexed tokenId, string key, string value); event AccountAdded(address owner, address account, uint totalAfter); event AccountRemoved(address owner, address account, uint totalAfter); constructor() MyERC721Metadata("CulturalArtTreasure", "CAT", 30000000) public { } // Mint and burn /** * @dev Mint token * * @param _to address of token owner */ function mint(address _to,uint256 amount) public returns (uint256) { require(_tokenIds.current() + amount < _max_supply, "CulturalArtTreasure: maximum quantity reached"); require(amount > 0, "You must buy at least one ."); uint256 newTokenId = 1; for (uint256 i = 0; i < amount; i++) { _tokenIds.increment(); newTokenId = _tokenIds.current(); _mint(_to, newTokenId); Attributes.Data storage attributes = attributesByTokenIds[newTokenId]; attributes.init(); } return newTokenId; } function burn(uint256 tokenId) public { _burn(msg.sender, tokenId); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (attributes.initialised) { attributes.removeAll(tokenId); delete attributesByTokenIds[tokenId]; } } // Attributes function numberOfAttributes(uint256 tokenId) public view returns (uint) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { return 0; } else { return attributes.length(); } } function getKey(uint256 tokenId, uint _index) public view returns (string memory) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (attributes.initialised) { if (_index < attributes.index.length) { return attributes.index[_index]; } } return ""; } function getValue(uint256 tokenId, string memory key) public view returns (uint _exists, uint _index, string memory _value) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { return (0, 0, ""); } else { Attributes.Value memory attribute = attributes.entries[key]; return (attribute.timestamp, attribute.index, attribute.value); } } function getAttributeByIndex(uint256 tokenId, uint256 _index) public view returns (string memory _key, string memory _value, uint timestamp) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (attributes.initialised) { if (_index < attributes.index.length) { string memory key = attributes.index[_index]; bytes memory keyInBytes = bytes(key); if (keyInBytes.length > 0) { Attributes.Value memory attribute = attributes.entries[key]; return (key, attribute.value, attribute.timestamp); } } } return ("", "", 0); } function addAttribute(uint256 tokenId, string memory key, string memory value) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: add attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { attributes.init(); } require(attributes.entries[key].timestamp == 0); attributes.add(tokenId, key, value); } function setAttribute(uint256 tokenId, string memory key, string memory value) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: set attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { attributes.init(); } if (attributes.entries[key].timestamp > 0) { attributes.setValue(tokenId, key, value); } else { attributes.add(tokenId, key, value); } } function removeAttribute(uint256 tokenId, string memory key) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: remove attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; require(attributes.initialised); attributes.remove(tokenId, key); } function updateAttribute(uint256 tokenId, string memory key, string memory value) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: update attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; require(attributes.initialised); require(attributes.entries[key].timestamp > 0); attributes.setValue(tokenId, key, value); } function isOwnerOf(uint tokenId, address account) public view returns (bool) { address owner = ownerOf(tokenId); if (owner == account) { return true; } else { Accounts.Data storage accounts = secondaryAccounts[owner]; if (accounts.initialised) { if (accounts.hasKey(account)) { return true; } } } return false; } function addSecondaryAccount(address account) public { require(account != address(0), "DreamChannelNFT: cannot add null secondary account"); Accounts.Data storage accounts = secondaryAccounts[msg.sender]; if (!accounts.initialised) { accounts.init(); } require(accounts.entries[account].timestamp == 0); accounts.add(msg.sender, account); } function removeSecondaryAccount(address account) public { require(account != address(0), "DreamChannelNFT: cannot remove null secondary account"); Accounts.Data storage accounts = secondaryAccounts[msg.sender]; require(accounts.initialised); accounts.remove(msg.sender, account); } function setTokenURI(uint256 tokenId, string memory _tokenURI) public{ require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: set Token URI of token that is not own"); _setTokenURI(tokenId, _tokenURI); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenIds.current(); } }
mint
function mint(address _to,uint256 amount) public returns (uint256) { require(_tokenIds.current() + amount < _max_supply, "CulturalArtTreasure: maximum quantity reached"); require(amount > 0, "You must buy at least one ."); uint256 newTokenId = 1; for (uint256 i = 0; i < amount; i++) { tokenIds.increment(); newTokenId = _tokenIds.current(); mint(_to, newTokenId); ttributes.Data storage attributes = attributesByTokenIds[newTokenId]; ttributes.init(); } return newTokenId; }
/** * @dev Mint token * * @param _to address of token owner */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 1421, 2003 ] }
5,673
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
CulturalArtTreasure
contract CulturalArtTreasure is MyERC721Metadata,IERC721Enumerable { using Attributes for Attributes.Data; using Attributes for Attributes.Value; using Counters for Counters.Counter; using Accounts for Accounts.Data; using Accounts for Accounts.Account; string public constant TYPE_KEY = "type"; string public constant SUBTYPE_KEY = "subtype"; string public constant NAME_KEY = "name"; string public constant DESCRIPTION_KEY = "description"; string public constant TAGS_KEY = "tags"; mapping(uint256 => Attributes.Data) private attributesByTokenIds; Counters.Counter private _tokenIds; mapping(address => Accounts.Data) private secondaryAccounts; // Duplicated from Attributes for NFT contract ABI to contain events event AttributeAdded(uint256 indexed tokenId, string key, string value, uint totalAfter); event AttributeRemoved(uint256 indexed tokenId, string key, uint totalAfter); event AttributeUpdated(uint256 indexed tokenId, string key, string value); event AccountAdded(address owner, address account, uint totalAfter); event AccountRemoved(address owner, address account, uint totalAfter); constructor() MyERC721Metadata("CulturalArtTreasure", "CAT", 30000000) public { } // Mint and burn /** * @dev Mint token * * @param _to address of token owner */ function mint(address _to,uint256 amount) public returns (uint256) { require(_tokenIds.current() + amount < _max_supply, "CulturalArtTreasure: maximum quantity reached"); require(amount > 0, "You must buy at least one ."); uint256 newTokenId = 1; for (uint256 i = 0; i < amount; i++) { _tokenIds.increment(); newTokenId = _tokenIds.current(); _mint(_to, newTokenId); Attributes.Data storage attributes = attributesByTokenIds[newTokenId]; attributes.init(); } return newTokenId; } function burn(uint256 tokenId) public { _burn(msg.sender, tokenId); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (attributes.initialised) { attributes.removeAll(tokenId); delete attributesByTokenIds[tokenId]; } } // Attributes function numberOfAttributes(uint256 tokenId) public view returns (uint) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { return 0; } else { return attributes.length(); } } function getKey(uint256 tokenId, uint _index) public view returns (string memory) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (attributes.initialised) { if (_index < attributes.index.length) { return attributes.index[_index]; } } return ""; } function getValue(uint256 tokenId, string memory key) public view returns (uint _exists, uint _index, string memory _value) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { return (0, 0, ""); } else { Attributes.Value memory attribute = attributes.entries[key]; return (attribute.timestamp, attribute.index, attribute.value); } } function getAttributeByIndex(uint256 tokenId, uint256 _index) public view returns (string memory _key, string memory _value, uint timestamp) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (attributes.initialised) { if (_index < attributes.index.length) { string memory key = attributes.index[_index]; bytes memory keyInBytes = bytes(key); if (keyInBytes.length > 0) { Attributes.Value memory attribute = attributes.entries[key]; return (key, attribute.value, attribute.timestamp); } } } return ("", "", 0); } function addAttribute(uint256 tokenId, string memory key, string memory value) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: add attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { attributes.init(); } require(attributes.entries[key].timestamp == 0); attributes.add(tokenId, key, value); } function setAttribute(uint256 tokenId, string memory key, string memory value) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: set attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { attributes.init(); } if (attributes.entries[key].timestamp > 0) { attributes.setValue(tokenId, key, value); } else { attributes.add(tokenId, key, value); } } function removeAttribute(uint256 tokenId, string memory key) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: remove attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; require(attributes.initialised); attributes.remove(tokenId, key); } function updateAttribute(uint256 tokenId, string memory key, string memory value) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: update attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; require(attributes.initialised); require(attributes.entries[key].timestamp > 0); attributes.setValue(tokenId, key, value); } function isOwnerOf(uint tokenId, address account) public view returns (bool) { address owner = ownerOf(tokenId); if (owner == account) { return true; } else { Accounts.Data storage accounts = secondaryAccounts[owner]; if (accounts.initialised) { if (accounts.hasKey(account)) { return true; } } } return false; } function addSecondaryAccount(address account) public { require(account != address(0), "DreamChannelNFT: cannot add null secondary account"); Accounts.Data storage accounts = secondaryAccounts[msg.sender]; if (!accounts.initialised) { accounts.init(); } require(accounts.entries[account].timestamp == 0); accounts.add(msg.sender, account); } function removeSecondaryAccount(address account) public { require(account != address(0), "DreamChannelNFT: cannot remove null secondary account"); Accounts.Data storage accounts = secondaryAccounts[msg.sender]; require(accounts.initialised); accounts.remove(msg.sender, account); } function setTokenURI(uint256 tokenId, string memory _tokenURI) public{ require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: set Token URI of token that is not own"); _setTokenURI(tokenId, _tokenURI); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenIds.current(); } }
numberOfAttributes
function numberOfAttributes(uint256 tokenId) public view returns (uint) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { return 0; } else { return attributes.length(); } }
// Attributes
LineComment
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 2342, 2637 ] }
5,674
CulturalArtTreasure
CulturalArtTreasure.sol
0x7d196c1f1afeea48364ad85587f593b42621787d
Solidity
CulturalArtTreasure
contract CulturalArtTreasure is MyERC721Metadata,IERC721Enumerable { using Attributes for Attributes.Data; using Attributes for Attributes.Value; using Counters for Counters.Counter; using Accounts for Accounts.Data; using Accounts for Accounts.Account; string public constant TYPE_KEY = "type"; string public constant SUBTYPE_KEY = "subtype"; string public constant NAME_KEY = "name"; string public constant DESCRIPTION_KEY = "description"; string public constant TAGS_KEY = "tags"; mapping(uint256 => Attributes.Data) private attributesByTokenIds; Counters.Counter private _tokenIds; mapping(address => Accounts.Data) private secondaryAccounts; // Duplicated from Attributes for NFT contract ABI to contain events event AttributeAdded(uint256 indexed tokenId, string key, string value, uint totalAfter); event AttributeRemoved(uint256 indexed tokenId, string key, uint totalAfter); event AttributeUpdated(uint256 indexed tokenId, string key, string value); event AccountAdded(address owner, address account, uint totalAfter); event AccountRemoved(address owner, address account, uint totalAfter); constructor() MyERC721Metadata("CulturalArtTreasure", "CAT", 30000000) public { } // Mint and burn /** * @dev Mint token * * @param _to address of token owner */ function mint(address _to,uint256 amount) public returns (uint256) { require(_tokenIds.current() + amount < _max_supply, "CulturalArtTreasure: maximum quantity reached"); require(amount > 0, "You must buy at least one ."); uint256 newTokenId = 1; for (uint256 i = 0; i < amount; i++) { _tokenIds.increment(); newTokenId = _tokenIds.current(); _mint(_to, newTokenId); Attributes.Data storage attributes = attributesByTokenIds[newTokenId]; attributes.init(); } return newTokenId; } function burn(uint256 tokenId) public { _burn(msg.sender, tokenId); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (attributes.initialised) { attributes.removeAll(tokenId); delete attributesByTokenIds[tokenId]; } } // Attributes function numberOfAttributes(uint256 tokenId) public view returns (uint) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { return 0; } else { return attributes.length(); } } function getKey(uint256 tokenId, uint _index) public view returns (string memory) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (attributes.initialised) { if (_index < attributes.index.length) { return attributes.index[_index]; } } return ""; } function getValue(uint256 tokenId, string memory key) public view returns (uint _exists, uint _index, string memory _value) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { return (0, 0, ""); } else { Attributes.Value memory attribute = attributes.entries[key]; return (attribute.timestamp, attribute.index, attribute.value); } } function getAttributeByIndex(uint256 tokenId, uint256 _index) public view returns (string memory _key, string memory _value, uint timestamp) { Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (attributes.initialised) { if (_index < attributes.index.length) { string memory key = attributes.index[_index]; bytes memory keyInBytes = bytes(key); if (keyInBytes.length > 0) { Attributes.Value memory attribute = attributes.entries[key]; return (key, attribute.value, attribute.timestamp); } } } return ("", "", 0); } function addAttribute(uint256 tokenId, string memory key, string memory value) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: add attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { attributes.init(); } require(attributes.entries[key].timestamp == 0); attributes.add(tokenId, key, value); } function setAttribute(uint256 tokenId, string memory key, string memory value) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: set attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; if (!attributes.initialised) { attributes.init(); } if (attributes.entries[key].timestamp > 0) { attributes.setValue(tokenId, key, value); } else { attributes.add(tokenId, key, value); } } function removeAttribute(uint256 tokenId, string memory key) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: remove attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; require(attributes.initialised); attributes.remove(tokenId, key); } function updateAttribute(uint256 tokenId, string memory key, string memory value) public { require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: update attribute of token that is not own"); require(keccak256(abi.encodePacked(key)) != keccak256(abi.encodePacked(TYPE_KEY))); Attributes.Data storage attributes = attributesByTokenIds[tokenId]; require(attributes.initialised); require(attributes.entries[key].timestamp > 0); attributes.setValue(tokenId, key, value); } function isOwnerOf(uint tokenId, address account) public view returns (bool) { address owner = ownerOf(tokenId); if (owner == account) { return true; } else { Accounts.Data storage accounts = secondaryAccounts[owner]; if (accounts.initialised) { if (accounts.hasKey(account)) { return true; } } } return false; } function addSecondaryAccount(address account) public { require(account != address(0), "DreamChannelNFT: cannot add null secondary account"); Accounts.Data storage accounts = secondaryAccounts[msg.sender]; if (!accounts.initialised) { accounts.init(); } require(accounts.entries[account].timestamp == 0); accounts.add(msg.sender, account); } function removeSecondaryAccount(address account) public { require(account != address(0), "DreamChannelNFT: cannot remove null secondary account"); Accounts.Data storage accounts = secondaryAccounts[msg.sender]; require(accounts.initialised); accounts.remove(msg.sender, account); } function setTokenURI(uint256 tokenId, string memory _tokenURI) public{ require(isOwnerOf(tokenId, msg.sender), "DreamChannelNFT: set Token URI of token that is not own"); _setTokenURI(tokenId, _tokenURI); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenIds.current(); } }
totalSupply
function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenIds.current(); }
/** * @dev See {IERC721Enumerable-totalSupply}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://fa498aaa5784baa128d9dd61551772349771a6bcd154a7206d741f3c775e15fb
{ "func_code_index": [ 7933, 8147 ] }
5,675
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 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 c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; }
/** * @dev Multiplies two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 89, 272 ] }
5,676
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 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 c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Integer division of two numbers, truncating the quotient. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 356, 629 ] }
5,677
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 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 c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; }
/** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 744, 860 ] }
5,678
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 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 c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; }
/** * @dev Adds two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 924, 1060 ] }
5,679
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
TokenVesting
contract TokenVesting is Ownable { using SafeMath for uint256; using SafeERC20 for ERC20Basic; event Released(uint256 amount); event Revoked(); // beneficiary of tokens after they are released address public beneficiary; uint256 public cliff; uint256 public start; uint256 public duration; bool public revocable; mapping (address => uint256) public released; mapping (address => bool) public revoked; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * _beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _cliff duration in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public { require(_beneficiary != address(0)); require(_cliff <= _duration); beneficiary = _beneficiary; revocable = _revocable; duration = _duration; cliff = _start.add(_cliff); start = _start; } /** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */ function release(ERC20Basic token) public { uint256 unreleased = releasableAmount(token); require(unreleased > 0); released[token] = released[token].add(unreleased); token.safeTransfer(beneficiary, unreleased); Released(unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param token ERC20 token which is being vested */ function revoke(ERC20Basic token) public onlyOwner { require(revocable); require(!revoked[token]); uint256 balance = token.balanceOf(this); uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); revoked[token] = true; token.safeTransfer(owner, refund); Revoked(); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */ function releasableAmount(ERC20Basic token) public view returns (uint256) { return vestedAmount(token).sub(released[token]); } /** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */ function vestedAmount(ERC20Basic token) public view returns (uint256) { uint256 currentBalance = token.balanceOf(this); uint256 totalBalance = currentBalance.add(released[token]); if (now < cliff) { return 0; } else if (now >= start.add(duration) || revoked[token]) { return totalBalance; } else { return totalBalance.mul(now.sub(start)).div(duration); } } }
/** * @title TokenVesting * @dev A token holder contract that can release its token balance gradually like a * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the * owner. */
NatSpecMultiLine
TokenVesting
function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public { require(_beneficiary != address(0)); require(_cliff <= _duration); beneficiary = _beneficiary; revocable = _revocable; duration = _duration; cliff = _start.add(_cliff); start = _start; }
/** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * _beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _cliff duration in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 1008, 1358 ] }
5,680
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
TokenVesting
contract TokenVesting is Ownable { using SafeMath for uint256; using SafeERC20 for ERC20Basic; event Released(uint256 amount); event Revoked(); // beneficiary of tokens after they are released address public beneficiary; uint256 public cliff; uint256 public start; uint256 public duration; bool public revocable; mapping (address => uint256) public released; mapping (address => bool) public revoked; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * _beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _cliff duration in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public { require(_beneficiary != address(0)); require(_cliff <= _duration); beneficiary = _beneficiary; revocable = _revocable; duration = _duration; cliff = _start.add(_cliff); start = _start; } /** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */ function release(ERC20Basic token) public { uint256 unreleased = releasableAmount(token); require(unreleased > 0); released[token] = released[token].add(unreleased); token.safeTransfer(beneficiary, unreleased); Released(unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param token ERC20 token which is being vested */ function revoke(ERC20Basic token) public onlyOwner { require(revocable); require(!revoked[token]); uint256 balance = token.balanceOf(this); uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); revoked[token] = true; token.safeTransfer(owner, refund); Revoked(); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */ function releasableAmount(ERC20Basic token) public view returns (uint256) { return vestedAmount(token).sub(released[token]); } /** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */ function vestedAmount(ERC20Basic token) public view returns (uint256) { uint256 currentBalance = token.balanceOf(this); uint256 totalBalance = currentBalance.add(released[token]); if (now < cliff) { return 0; } else if (now >= start.add(duration) || revoked[token]) { return totalBalance; } else { return totalBalance.mul(now.sub(start)).div(duration); } } }
/** * @title TokenVesting * @dev A token holder contract that can release its token balance gradually like a * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the * owner. */
NatSpecMultiLine
release
function release(ERC20Basic token) public { uint256 unreleased = releasableAmount(token); require(unreleased > 0); released[token] = released[token].add(unreleased); token.safeTransfer(beneficiary, unreleased); Released(unreleased); }
/** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 1482, 1755 ] }
5,681
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
TokenVesting
contract TokenVesting is Ownable { using SafeMath for uint256; using SafeERC20 for ERC20Basic; event Released(uint256 amount); event Revoked(); // beneficiary of tokens after they are released address public beneficiary; uint256 public cliff; uint256 public start; uint256 public duration; bool public revocable; mapping (address => uint256) public released; mapping (address => bool) public revoked; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * _beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _cliff duration in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public { require(_beneficiary != address(0)); require(_cliff <= _duration); beneficiary = _beneficiary; revocable = _revocable; duration = _duration; cliff = _start.add(_cliff); start = _start; } /** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */ function release(ERC20Basic token) public { uint256 unreleased = releasableAmount(token); require(unreleased > 0); released[token] = released[token].add(unreleased); token.safeTransfer(beneficiary, unreleased); Released(unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param token ERC20 token which is being vested */ function revoke(ERC20Basic token) public onlyOwner { require(revocable); require(!revoked[token]); uint256 balance = token.balanceOf(this); uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); revoked[token] = true; token.safeTransfer(owner, refund); Revoked(); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */ function releasableAmount(ERC20Basic token) public view returns (uint256) { return vestedAmount(token).sub(released[token]); } /** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */ function vestedAmount(ERC20Basic token) public view returns (uint256) { uint256 currentBalance = token.balanceOf(this); uint256 totalBalance = currentBalance.add(released[token]); if (now < cliff) { return 0; } else if (now >= start.add(duration) || revoked[token]) { return totalBalance; } else { return totalBalance.mul(now.sub(start)).div(duration); } } }
/** * @title TokenVesting * @dev A token holder contract that can release its token balance gradually like a * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the * owner. */
NatSpecMultiLine
revoke
function revoke(ERC20Basic token) public onlyOwner { require(revocable); require(!revoked[token]); uint256 balance = token.balanceOf(this); uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); revoked[token] = true; token.safeTransfer(owner, refund); Revoked(); }
/** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param token ERC20 token which is being vested */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 1967, 2321 ] }
5,682
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
TokenVesting
contract TokenVesting is Ownable { using SafeMath for uint256; using SafeERC20 for ERC20Basic; event Released(uint256 amount); event Revoked(); // beneficiary of tokens after they are released address public beneficiary; uint256 public cliff; uint256 public start; uint256 public duration; bool public revocable; mapping (address => uint256) public released; mapping (address => bool) public revoked; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * _beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _cliff duration in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public { require(_beneficiary != address(0)); require(_cliff <= _duration); beneficiary = _beneficiary; revocable = _revocable; duration = _duration; cliff = _start.add(_cliff); start = _start; } /** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */ function release(ERC20Basic token) public { uint256 unreleased = releasableAmount(token); require(unreleased > 0); released[token] = released[token].add(unreleased); token.safeTransfer(beneficiary, unreleased); Released(unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param token ERC20 token which is being vested */ function revoke(ERC20Basic token) public onlyOwner { require(revocable); require(!revoked[token]); uint256 balance = token.balanceOf(this); uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); revoked[token] = true; token.safeTransfer(owner, refund); Revoked(); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */ function releasableAmount(ERC20Basic token) public view returns (uint256) { return vestedAmount(token).sub(released[token]); } /** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */ function vestedAmount(ERC20Basic token) public view returns (uint256) { uint256 currentBalance = token.balanceOf(this); uint256 totalBalance = currentBalance.add(released[token]); if (now < cliff) { return 0; } else if (now >= start.add(duration) || revoked[token]) { return totalBalance; } else { return totalBalance.mul(now.sub(start)).div(duration); } } }
/** * @title TokenVesting * @dev A token holder contract that can release its token balance gradually like a * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the * owner. */
NatSpecMultiLine
releasableAmount
function releasableAmount(ERC20Basic token) public view returns (uint256) { return vestedAmount(token).sub(released[token]); }
/** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 2478, 2615 ] }
5,683
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
TokenVesting
contract TokenVesting is Ownable { using SafeMath for uint256; using SafeERC20 for ERC20Basic; event Released(uint256 amount); event Revoked(); // beneficiary of tokens after they are released address public beneficiary; uint256 public cliff; uint256 public start; uint256 public duration; bool public revocable; mapping (address => uint256) public released; mapping (address => bool) public revoked; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * _beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _cliff duration in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public { require(_beneficiary != address(0)); require(_cliff <= _duration); beneficiary = _beneficiary; revocable = _revocable; duration = _duration; cliff = _start.add(_cliff); start = _start; } /** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */ function release(ERC20Basic token) public { uint256 unreleased = releasableAmount(token); require(unreleased > 0); released[token] = released[token].add(unreleased); token.safeTransfer(beneficiary, unreleased); Released(unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param token ERC20 token which is being vested */ function revoke(ERC20Basic token) public onlyOwner { require(revocable); require(!revoked[token]); uint256 balance = token.balanceOf(this); uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); revoked[token] = true; token.safeTransfer(owner, refund); Revoked(); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */ function releasableAmount(ERC20Basic token) public view returns (uint256) { return vestedAmount(token).sub(released[token]); } /** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */ function vestedAmount(ERC20Basic token) public view returns (uint256) { uint256 currentBalance = token.balanceOf(this); uint256 totalBalance = currentBalance.add(released[token]); if (now < cliff) { return 0; } else if (now >= start.add(duration) || revoked[token]) { return totalBalance; } else { return totalBalance.mul(now.sub(start)).div(duration); } } }
/** * @title TokenVesting * @dev A token holder contract that can release its token balance gradually like a * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the * owner. */
NatSpecMultiLine
vestedAmount
function vestedAmount(ERC20Basic token) public view returns (uint256) { uint256 currentBalance = token.balanceOf(this); uint256 totalBalance = currentBalance.add(released[token]); if (now < cliff) { return 0; } else if (now >= start.add(duration) || revoked[token]) { return totalBalance; } else { return totalBalance.mul(now.sub(start)).div(duration); } }
/** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 2743, 3158 ] }
5,684
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
startTde
function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); }
/** * @dev Allows contract owner to start the TDE. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 2167, 2452 ] }
5,685
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
stopTde
function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); }
/** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 2605, 2813 ] }
5,686
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
extendTde
function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); }
/** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 2956, 3090 ] }
5,687
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
shortenTde
function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); }
/** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 3229, 3364 ] }
5,688
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
setTdeIssuer
function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; }
/** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 3514, 3644 ] }
5,689
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
setOperationalReserveAddress
function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; }
/** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 3857, 4071 ] }
5,690
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
issueFTT
function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; }
/** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 4234, 4861 ] }
5,691
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
fttIssued
function fttIssued() external view returns (uint256) { return fttIssued; }
/** * @dev Returns amount of FTT issued. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 4925, 5050 ] }
5,692
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
finalize
function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); }
/** * @dev Allows the contract owner to finalize the TDE. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 5131, 6422 ] }
5,693
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; }
/** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 6765, 7317 ] }
5,694
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
transfer
function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; }
/** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 7538, 7957 ] }
5,695
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
approve
function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; }
/** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 8609, 8880 ] }
5,696
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
balanceOf
function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; }
/** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 9096, 9248 ] }
5,697
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
allowance
function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; }
/** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 9584, 9755 ] }
5,698
FTT
FTT.sol
0x2aec18c5500f21359ce1bea5dc1777344df4c0dc
Solidity
FTT
contract FTT is Ownable { using SafeMath for uint256; uint256 public totalSupply = 1000000000 * 10**uint256(decimals); string public constant name = "FarmaTrust Token"; string public symbol = "FTT"; uint8 public constant decimals = 18; mapping(address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); event FTTIssued(address indexed from, address indexed to, uint256 indexed amount, uint256 timestamp); event TdeStarted(uint256 startTime); event TdeStopped(uint256 stopTime); event TdeFinalized(uint256 finalizeTime); // Amount of FTT available during tok0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3Een distribution event. uint256 public constant FT_TOKEN_SALE_CAP = 600000000 * 10**uint256(decimals); // Amount held for operational usage. uint256 public FT_OPERATIONAL_FUND = totalSupply - FT_TOKEN_SALE_CAP; // Amount held for team usage. uint256 public FT_TEAM_FUND = FT_OPERATIONAL_FUND / 10; // Amount of FTT issued. uint256 public fttIssued = 0; address public tdeIssuer = 0x2Ec9F52A5e4E7B5e20C031C1870Fd952e1F01b3E; address public teamVestingAddress; address public unsoldVestingAddress; address public operationalReserveAddress; bool public tdeActive; bool public tdeStarted; bool public isFinalized = false; bool public capReached; uint256 public tdeDuration = 60 days; uint256 public tdeStartTime; function FTT() public { } modifier onlyTdeIssuer { require(msg.sender == tdeIssuer); _; } modifier tdeRunning { require(tdeActive && block.timestamp < tdeStartTime + tdeDuration); _; } modifier tdeEnded { require(((!tdeActive && block.timestamp > tdeStartTime + tdeDuration) && tdeStarted) || capReached); _; } /** * @dev Allows contract owner to start the TDE. */ function startTde() public onlyOwner { require(!isFinalized); tdeActive = true; tdeStarted = true; if (tdeStartTime == 0) { tdeStartTime = block.timestamp; } TdeStarted(tdeStartTime); } /** * @dev Allows contract owner to stop and optionally restart the TDE. * @param _restart Resets the tdeStartTime if true. */ function stopTde(bool _restart) external onlyOwner { tdeActive = false; if (_restart) { tdeStartTime = 0; } TdeStopped(block.timestamp); } /** * @dev Allows contract owner to increase TDE period. * @param _time amount of time to increase TDE period by. */ function extendTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.add(_time); } /** * @dev Allows contract owner to reduce TDE period. * @param _time amount of time to reduce TDE period by. */ function shortenTde(uint256 _time) external onlyOwner { tdeDuration = tdeDuration.sub(_time); } /** * @dev Allows contract owner to set the FTT issuing authority. * @param _tdeIssuer address of FTT issuing authority. */ function setTdeIssuer(address _tdeIssuer) external onlyOwner { tdeIssuer = _tdeIssuer; } /** * @dev Allows contract owner to set the beneficiary of the FT operational reserve amount of FTT. * @param _operationalReserveAddress address of FT operational reserve beneficiary. */ function setOperationalReserveAddress(address _operationalReserveAddress) external onlyOwner tdeRunning { operationalReserveAddress = _operationalReserveAddress; } /** * @dev Issues FTT to entitled accounts. * @param _user address to issue FTT to. * @param _fttAmount amount of FTT to issue. */ function issueFTT(address _user, uint256 _fttAmount) public onlyTdeIssuer tdeRunning returns(bool) { uint256 newAmountIssued = fttIssued.add(_fttAmount); require(_user != address(0)); require(_fttAmount > 0); require(newAmountIssued <= FT_TOKEN_SALE_CAP); balances[_user] = balances[_user].add(_fttAmount); fttIssued = newAmountIssued; FTTIssued(tdeIssuer, _user, _fttAmount, block.timestamp); if (fttIssued == FT_TOKEN_SALE_CAP) { capReached = true; } return true; } /** * @dev Returns amount of FTT issued. */ function fttIssued() external view returns (uint256) { return fttIssued; } /** * @dev Allows the contract owner to finalize the TDE. */ function finalize() external tdeEnded onlyOwner { require(!isFinalized); // Deposit team fund amount into team vesting contract. uint256 teamVestingCliff = 15778476; // 6 months uint256 teamVestingDuration = 1 years; TokenVesting teamVesting = new TokenVesting(owner, now, teamVestingCliff, teamVestingDuration, true); teamVesting.transferOwnership(owner); teamVestingAddress = address(teamVesting); balances[teamVestingAddress] = FT_TEAM_FUND; if (!capReached) { // Deposit unsold FTT into unsold vesting contract. uint256 unsoldVestingCliff = 3 years; uint256 unsoldVestingDuration = 10 years; TokenVesting unsoldVesting = new TokenVesting(owner, now, unsoldVestingCliff, unsoldVestingDuration, true); unsoldVesting.transferOwnership(owner); unsoldVestingAddress = address(unsoldVesting); balances[unsoldVestingAddress] = FT_TOKEN_SALE_CAP - fttIssued; } // Allocate operational reserve of FTT. balances[operationalReserveAddress] = FT_OPERATIONAL_FUND - FT_TEAM_FUND; isFinalized = true; TdeFinalized(block.timestamp); } /** * @dev Transfer tokens from one address to another. Trading limited - requires the TDE to have ended. * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Transfer token for a specified address. Trading limited - requires the TDE to have ended. * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { if (!isFinalized) return false; require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _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 balance) { return balances[_owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
increaseApproval
function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
/** * approve should be called when allowed[_spender] == 0. To increment * allowed value, it is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://4b697d3aa64f916ecc42d2a9da9b72646beda153a58942612cd9cd6fca6f5004
{ "func_code_index": [ 9981, 10292 ] }
5,699