Created
May 22, 2018 03:35
-
-
Save stefanbemelmans/2fdede3c7b32ac2da069b5c0b263b9f9 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
/* | |
Copyright (c) 2018 HERC SEZC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
*/ | |
library Addresses { | |
function isContract(address _base) internal constant returns (bool) { | |
uint codeSize; | |
assembly { | |
codeSize := extcodesize(_base) | |
} | |
return codeSize > 0; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.24; | |
/* | |
Copyright (c) 2018 HERC SEZC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
*/ | |
interface ERC20 { | |
function transferFrom(address _from, address _to, uint _value) external returns (bool); | |
function approve(address _spender, uint _value) external returns (bool); | |
function allowance(address _owner, address _spender) external view returns (uint); | |
event Approval(address indexed _owner, address indexed _spender, uint _value); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
/* | |
Copyright (c) 2018 HERC SEZC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
*/ | |
interface ERC223 { | |
function transfer(address _to, uint _value, bytes _data) external returns (bool); | |
event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
/* | |
Copyright (c) 2018 HERC SEZC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
*/ | |
interface ERC223ReceivingContract { | |
function tokenFallback(address _from, uint _value, bytes _data) external; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
/* | |
Copyright (c) 2018 HERC SEZC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
*/ | |
import "./Token.sol"; | |
import "./ERC20.sol"; | |
import "./ERC223.sol"; | |
import "./ERC223ReceivingContract.sol"; | |
import "./SafeMath.sol"; | |
import "./Addresses.sol"; | |
contract HERCToken is Token("HERC", "Hercules", 18, 234259085), ERC20, ERC223 { | |
using SafeMath for uint; | |
using Addresses for address; | |
uint256 _totalSupply; | |
address private owner; | |
constructor () public { | |
_balanceOf[msg.sender] = _totalSupply; | |
owner = msg.sender; | |
} | |
modifier isOwner { | |
require(owner == msg.sender); | |
_; | |
} | |
// function totalSupply() constant returns (uint256 totalSupply) { | |
// totalSupply = _totalSupply; | |
// } | |
function totalSupply() | |
public | |
view | |
returns (uint) { | |
return _totalSupply; | |
} | |
function balanceOf(address _addr) | |
public | |
view | |
returns (uint) { | |
return _balanceOf[_addr]; | |
} | |
// function transfer(address _to, uint _value) | |
// public | |
// returns (bool) { | |
// return transfer(_to, _value, ""); | |
// } | |
function transfer(address _to, uint _value, bytes _data) | |
isOwner | |
external | |
returns (bool) { | |
if (_value > 0 && | |
_value <= _balanceOf[msg.sender]) { | |
if (_to.isContract()) { | |
ERC223ReceivingContract _contract = ERC223ReceivingContract(_to); | |
_contract.tokenFallback(msg.sender, _value, _data); | |
} | |
_balanceOf[msg.sender] = _balanceOf[msg.sender].sub(_value); | |
_balanceOf[_to] = _balanceOf[_to].add(_value); | |
return true; | |
} | |
return false; | |
} | |
// function transferFrom(address _from, address _to, uint _value) | |
// public | |
// returns (bool) { | |
// return transferFrom(_from, _to, _value, ""); | |
// } | |
function transferFrom(address _from, address _to, uint _value, bytes _data) | |
public | |
returns (bool) { | |
if (_allowances[_from][msg.sender] > 0 && | |
_value > 0 && | |
_allowances[_from][msg.sender] >= _value && | |
_balanceOf[_from] >= _value) { | |
_allowances[_from][msg.sender] -= _value; | |
if (_to.isContract()) { | |
ERC223ReceivingContract _contract = ERC223ReceivingContract(_to); | |
_contract.tokenFallback(msg.sender, _value, _data); | |
} | |
_balanceOf[_from] = _balanceOf[_from].sub(_value); | |
_balanceOf[_to] = _balanceOf[_to].add(_value); | |
emit Transfer(_from, _to, _value); | |
return true; | |
} | |
return false; | |
} | |
function approve(address _spender, uint _value) | |
public | |
returns (bool) { | |
if (_balanceOf[msg.sender] >= _value) { | |
_allowances[msg.sender][_spender] = _value; | |
emit Approval(msg.sender, _spender, _value); | |
return true; | |
} | |
return false; | |
} | |
function allowance(address _owner, address _spender) | |
public | |
view | |
returns (uint) { | |
if (_allowances[_owner][_spender] < _balanceOf[_owner]) { | |
return _allowances[_owner][_spender]; | |
} | |
return _balanceOf[_owner]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.17; | |
import "./HERCToken.sol"; | |
contract HercTrans is HERCToken{ | |
// herc contract ropsten address 0x0C97b0B42140D77dE45Fc669E826225E6bb6B3D2 | |
address public _herc; | |
address public _user = msg.sender; | |
uint _chainFee; | |
uint _viewerFee; | |
uint _hiprWin; | |
modifier validValue { | |
assert(msg.value <= balanceOf(msg.sender)); | |
_; | |
} | |
function _createFee() payable isOwner validValue public { | |
transfer(_herc, 10000); | |
} | |
function supplyChain() payable isOwner validValue public { | |
transfer(_herc, _chainFee); | |
} | |
function digitalViewer() payable isOwner validValue public { | |
transfer(_herc, _viewerFee); | |
} | |
function hiprWin() payable isOwner validValue public { | |
transfer(_user, _hiprWin); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @title Ownable | |
* @dev The Ownable contract has an owner address, and provides basic authorization control | |
* functions, this simplifies the implementation of "user permissions". | |
*/ | |
pragma solidity ^0.4.24; | |
contract Ownable { | |
address public owner; | |
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); | |
/** | |
* @dev The Ownable constructor sets the original `owner` of the contract to the sender | |
* account. | |
*/ | |
constructor() public { | |
owner = msg.sender; | |
} | |
/** | |
* @dev Throws if called by any account other than the owner. | |
*/ | |
modifier onlyOwner() { | |
require(msg.sender == owner); | |
_; | |
} | |
/** | |
* @dev Allows the current owner to transfer control of the contract to a newOwner. | |
* @param newOwner The address to transfer ownership to. | |
*/ | |
function transferOwnership(address newOwner) public onlyOwner { | |
require(newOwner != address(0)); | |
emit OwnershipTransferred(owner, newOwner); | |
owner = newOwner; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
/* | |
Copyright (c) 2018 HERC SEZC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
*/ | |
library SafeMath { | |
function sub(uint _base, uint _value) | |
internal | |
pure | |
returns (uint) { | |
assert(_value <= _base); | |
return _base - _value; | |
} | |
function add(uint _base, uint _value) | |
internal | |
pure | |
returns (uint _ret) { | |
_ret = _base + _value; | |
assert(_ret >= _base); | |
} | |
function div(uint _base, uint _value) | |
internal | |
pure | |
returns (uint) { | |
assert(_value > 0 && (_base % _value) == 0); | |
return _base / _value; | |
} | |
function mul(uint _base, uint _value) | |
internal | |
pure | |
returns (uint _ret) { | |
_ret = _base * _value; | |
assert(0 == _base || _ret / _base == _value); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
/* | |
Copyright (c) 2018 HERC SEZC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
*/ | |
contract Token { | |
string internal _symbol; | |
string internal _name; | |
uint8 internal _decimals; | |
uint internal _totalSupply; | |
mapping (address => uint) internal _balanceOf; | |
mapping (address => mapping (address => uint)) internal _allowances; | |
constructor (string symbol, string name, uint8 decimals, uint totalSupply) public { | |
_symbol = symbol; | |
_name = name; | |
_decimals = decimals; | |
_totalSupply = totalSupply; | |
} | |
function name() | |
public | |
view | |
returns (string) { | |
return _name; | |
} | |
function symbol() | |
public | |
view | |
returns (string) { | |
return _symbol; | |
} | |
function decimals() | |
public | |
view | |
returns (uint8) { | |
return _decimals; | |
} | |
function totalSupply() | |
public | |
view | |
returns (uint) { | |
return _totalSupply; | |
} | |
function balanceOf(address _addr) public view returns (uint); | |
function transfer(address _to, uint _value) public returns (bool); | |
event Transfer(address indexed _from, address indexed _to, uint _value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment