Created
May 25, 2018 12:31
-
-
Save VeioCoin/ed6086a16e7df08563567cb7beccf5ba 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 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.11; | |
interface IERC20 { | |
function totalSupply() constant returns (uint256 totalSupply); | |
function balanceOf(address _owner) constant returns (uint256 balance); | |
function transfer(address _to, uint256 _value) returns (bool success); | |
function transferFrom(address _from, address _to, uint256 _value) returns (bool success); | |
function approve(address _spender, uint256 _value) returns (bool success); | |
function allowance(address _owner, address _spender) constant returns (uint256 remaining); | |
event Transfer(address indexed _from, address indexed _to, uint256 _value); | |
event Approval(address indexed _owner, address indexed _spender, uint256 _value); | |
} |
This file contains 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.11; | |
library SafeMath { | |
function mul(uint a, uint b) internal returns (uint) { | |
uint c = a * b; | |
assert(a == 0 || c / a == b); | |
return c; | |
} | |
function div(uint a, uint b) internal returns (uint) { | |
assert(b > 0); | |
uint c = a / b; | |
assert(a == b * c + a % b); | |
return c; | |
} | |
function sub(uint a, uint b) internal returns (uint) { | |
assert(b <= a); | |
return a - b; | |
} | |
function add(uint a, uint b) internal returns (uint) { | |
uint c = a + b; | |
assert(c >= a); | |
return c; | |
} | |
function max64(uint64 a, uint64 b) internal constant returns (uint64) { | |
return a >= b ? a : b; | |
} | |
function min64(uint64 a, uint64 b) internal constant returns (uint64) { | |
return a < b ? a : b; | |
} | |
function max256(uint256 a, uint256 b) internal constant returns (uint256) { | |
return a >= b ? a : b; | |
} | |
function min256(uint256 a, uint256 b) internal constant returns (uint256) { | |
return a < b ? a : b; | |
} | |
function assert(bool assertion) internal { | |
if (!assertion) { | |
throw; | |
} | |
} | |
} |
This file contains 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.11; | |
import './IERC20.sol'; | |
import './SafeMath.sol'; | |
contract VeioCoin is IERC20 { | |
using SafeMath for uint256; | |
uint public _totalSupply = 0; | |
string public constant symbol = "VEO"; | |
string public constant name = "Veio Coin"; | |
uint8 public constant decimals = 18; | |
uint256 public constant RATE = 10000; | |
address public owner; | |
mapping(address => uint256 ) balances; | |
mapping(address => mapping(address => uint256)) allowed; | |
function () payable { | |
createTokens(); | |
} | |
function VeioCoin(){ | |
// balances[msg.sender] = _totalSupply; | |
owner = msg.sender; | |
} | |
function createTokens() payable { | |
require(msg.value > 0); | |
uint256 tokens = msg.value.mul(RATE); | |
balances[msg.sender] = balances[msg.sender].add(tokens); | |
_totalSupply = _totalSupply.add(tokens); | |
owner.transfer(msg.value); | |
} | |
function totalSupply() constant returns (uint256 totalSupply){ | |
return _totalSupply; | |
} | |
function balanceOf(address _owner) constant returns (uint256 balance){ | |
return balances[_owner]; | |
} | |
function transfer(address _to, uint256 _value) returns (bool success){ | |
require( | |
balances[msg.sender] >= _value | |
&& _value > 0 | |
); | |
balances[msg.sender] = balances[msg.sender].sub(_value); | |
balances[_to] = balances[_to].sub(_value); | |
Transfer(msg.sender, _to, _value); | |
return true; | |
} | |
function transferFrom(address _from, address _to, uint256 _value) returns (bool success){ | |
require( | |
allowed[_from][msg.sender] >= _value | |
&& balances[_from] >= _value | |
&& _value > 0 | |
); | |
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; | |
} | |
function approve(address _spender, uint256 _value) returns (bool success){ | |
allowed[msg.sender][_spender] = _value; | |
Approval(msg.sender, _spender, _value); | |
return true; | |
} | |
function allowance(address _owner, address _spender) constant returns (uint256 remaining){ | |
return allowed[_owner][_spender]; | |
} | |
event Transfer(address indexed _from, address indexed _to, uint256 _value); | |
event Approval(address indexed _owner, address indexed _spender, uint256 _value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment